WPS Office.apk(点击下载) / fof.java


package defpackage;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.os.RemoteException;
import android.text.TextUtils;
import cn.wps.moffice.OfficeApp;
import cn.wps.moffice.common.cpevent.CPEventHandler;
import cn.wps.moffice.define.VersionManager;
import cn.wps.moffice.main.common.ServerParamsUtil;
import cn.wps.moffice.runtime.broadcast.WatchingPreferenceBroadcast;
import cn.wps.util.JSONUtil;
import defpackage.cqb;
import defpackage.eip;
import defpackage.fop;
import defpackage.foq;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Stack;

/* renamed from: fof  reason: default package */
public final class fof implements sym {
    protected static final String TAG = null;
    protected boolean geq;
    protected fop ger;
    protected Stack<Runnable> ges = null;
    private foq geu = new foq.a() {
        /* class defpackage.fof.AnonymousClass2 */

        @Override // defpackage.foq
        public final void bBl() throws RemoteException {
            fcz.b(new Runnable() {
                /* class defpackage.fof.AnonymousClass2.AnonymousClass1 */

                public final void run() {
                    fpi.bCu().lo(true);
                    try {
                        fzc.bJM().b(fzd.homepage_refresh, false, true);
                        fzc.bJM().b(fzd.home_show_roaming_reload_tips, new Object[0]);
                    } catch (Exception e) {
                    }
                }
            }, false);
        }

        @Override // defpackage.foq
        public final void bBm() throws RemoteException {
        }

        @Override // defpackage.foq
        public final void bBn() throws RemoteException {
            fzc.bJM().a(fzd.qing_login_out, new Object[0]);
            fzc.bJM().a(fzd.roamingtipsbar_login_out, new Object[0]);
            fzc.bJM().a(fzd.clouddocs_login_out, new Object[0]);
            fzc.bJM().a(fzd.home_roaming_page_login_out, new Object[0]);
            fze.bJN().a(fzd.qing_login_out, new Object[0]);
        }

        @Override // defpackage.foq
        public final void lh(boolean z) throws RemoteException {
            fzc.bJM().a(fzd.qing_roaming_file_list_refresh_all, true, Boolean.valueOf(z));
            fzc.bJM().a(fzd.qing_roaming_star_list_refresh_all, true, Boolean.valueOf(z));
        }
    };
    protected Context mAppContext = OfficeApp.arx();
    private ServiceConnection mConnection = new ServiceConnection() {
        /* class defpackage.fof.AnonymousClass1 */

        public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            fof.this.ger = fop.a.i(iBinder);
            fof.this.geq = true;
            fof.a(fof.this);
            ebg.eyy = 20;
            fof.this.lf(true);
            fof.this.bBc();
            try {
                if (fof.this.ger.bBK()) {
                    long j = 0;
                    if (ServerParamsUtil.tH("func_wpscloud_autoupload_limit")) {
                        j = flh.byK();
                    }
                    fof.this.ger.Y(j);
                    ebg.eyH = j;
                    fof.this.ger.a(true, (Cfor) new foy() {
                        /* class defpackage.fof.AnonymousClass1.AnonymousClass1 */
                    });
                    fof.this.ger.lj(true);
                }
            } catch (RemoteException e) {
                lve.a("ERROR", fof.TAG, "onServiceConnected. set switch / set force upload filesize error.", e);
            }
            if (ebo.aSq() && fof.bBi()) {
                fzk.uD("AC_ROAMING_LOGIN_SUCCESS");
                fzk.R(".RoamingFragment", false);
                fzc.bJM().a(fzd.qing_roaming_file_list_refresh_all, true, true);
            }
            fzc.bJM().a(fzd.qing_service_connected, new Object[0]);
            fzc.bJM().a(fzd.qing_service_connected_for_find_lost_file, new Object[0]);
            CPEventHandler.aEi().a(fof.this.mAppContext, dgk.qing_service_connected, (Parcelable) null);
            fof.b(fof.this);
        }

        public final void onServiceDisconnected(ComponentName componentName) {
            fof.this.ger = null;
            fof.this.geq = false;
        }
    };

    /* renamed from: fof$a */
    public static class a<T> extends foy {
        Type geA;
        Class<T> geB;
        T geC;
        foh<T> gey;
        foh<ArrayList<T>> gez;

        public a(foh<T> foh, T t, Class<T> cls) {
            this.gey = foh;
            this.geB = cls;
            this.geC = t;
        }

        public a(foh<ArrayList<T>> foh, Type type) {
            this.gez = foh;
            this.geA = type;
        }

        private static int o(Bundle bundle) {
            if (bundle == null) {
                return -1;
            }
            try {
                return Integer.parseInt(bundle.getString("key_result"));
            } catch (NumberFormatException e) {
                return -1;
            }
        }

        @Override // defpackage.foy, defpackage.Cfor
        public final void j(long j, long j2) throws RemoteException {
            if (this.gey != null) {
                this.gey.P(j);
            }
        }

        @Override // defpackage.foy, defpackage.Cfor
        public final void m(Bundle bundle) throws RemoteException {
            int o = o(bundle);
            String str = null;
            if (bundle != null) {
                str = bundle.getString("KEY_RESULT_ERR_MSG");
            }
            if (this.gez == null) {
                this.gey.onError(o, str);
            } else {
                this.gez.onError(o, str);
            }
        }

        /* JADX DEBUG: Multi-variable search result rejected for r0v4, resolved type: foh<T> */
        /* JADX WARN: Multi-variable type inference failed */
        @Override // defpackage.foy, defpackage.Cfor
        public final void n(Bundle bundle) throws RemoteException {
            if (this.gez == null) {
                foh<T> foh = this.gey;
                T t = this.geC;
                Class<T> cls = this.geB;
                if (bundle == null) {
                    foh.s(t);
                } else if ("key_status_ok".equals(bundle.getString("key_status_code"))) {
                    String string = bundle.getString("key_result");
                    if (TextUtils.isEmpty(string)) {
                        foh.s(t);
                    } else {
                        foh.s(JSONUtil.instance(string, cls));
                    }
                }
            } else {
                foh<ArrayList<T>> foh2 = this.gez;
                Type type = this.geA;
                ArrayList<T> arrayList = new ArrayList<>();
                if (bundle == null) {
                    foh2.s(arrayList);
                } else if ("key_status_ok".equals(bundle.getString("key_status_code"))) {
                    String string2 = bundle.getString("key_result");
                    if (TextUtils.isEmpty(string2)) {
                        foh2.s(arrayList);
                    } else {
                        foh2.s((ArrayList) JSONUtil.getGson().fromJson(string2, type));
                    }
                }
            }
        }

        @Override // defpackage.foy, defpackage.Cfor
        public final void onProgress(long j, long j2) throws RemoteException {
            if (this.gez == null) {
                this.gey.onProgress(j, j2);
            } else {
                this.gez.onProgress(j, j2);
            }
        }

        @Override // defpackage.foy, defpackage.Cfor
        public final void onSuccess() throws RemoteException {
            if (this.gez == null) {
                this.gey.onSuccess();
            } else {
                this.gez.onSuccess();
            }
        }
    }

    protected fof() {
        syo.a(this.mAppContext, this);
        bindService();
    }

    static /* synthetic */ void a(fof fof) {
        if (cqt.asq()) {
            try {
                fof.ger.a(eip.b.HOME.name(), fof.geu);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }

    static /* synthetic */ void b(fof fof) {
        while (!fof.bAZ().empty()) {
            fof.bAZ().pop().run();
        }
    }

    public static boolean bBi() {
        return !VersionManager.aYS() && !cqb.a.cow.cos.aXT();
    }

    private synchronized void bindService() {
        if (!this.geq) {
            Intent intent = new Intent();
            intent.setClassName(this.mAppContext, "cn.wps.moffice.main.cloud.roaming.service.WPSQingService");
            intent.setAction("cn.wps.moffice.qing.service");
            this.mAppContext.getApplicationContext().bindService(intent, this.mConnection, 1);
        }
    }

    public final void B(boolean z, boolean z2) {
        bBa();
        if (this.ger != null) {
            try {
                this.ger.D(z, z2);
            } catch (RemoteException e) {
            }
        }
        dwp.at("public_login_menberid", String.valueOf(cvn.avc()));
    }

    public final void Q(long j) {
        if (this.ger != null) {
            try {
                long j2 = ebg.eyB;
                this.ger.W(j);
                fqd.Z(j);
                if (j2 != ebg.eyB) {
                    WatchingPreferenceBroadcast.h(this.mAppContext, ebg.eyB);
                }
                new StringBuilder("setUploadFileSizeLimit: ").append((j / 1024) / 1024).append("M");
            } catch (RemoteException e) {
            }
        }
    }

    public final void R(long j) {
        if (this.ger != null) {
            try {
                this.ger.X(j);
                new StringBuilder("setAvailableSize: ").append((j / 1024) / 1024).append("M");
            } catch (RemoteException e) {
            }
        }
    }

    public final long a(boolean z, foh<Void> foh) {
        if (this.ger != null) {
            try {
                return this.ger.a(z, new a(foh, null, Void.class));
            } catch (RemoteException e) {
            }
        }
        return -1;
    }

    /* access modifiers changed from: protected */
    public final Stack<Runnable> bAZ() {
        if (this.ges == null) {
            this.ges = new Stack<>();
        }
        return this.ges;
    }

    @Override // defpackage.sym
    public final String bAz() {
        if (!bBj()) {
            String str = ebg.eyt;
            fnw.rq(VersionManager.aYQ() ? ebg.eyt : "https://account.wps.com");
        }
        return fnw.bAz();
    }

    /* access modifiers changed from: protected */
    public final boolean bBa() {
        if (!this.geq || this.ger == null) {
            bindService();
        }
        return this.geq;
    }

    public final String bBb() {
        bBa();
        if (this.ger != null) {
            try {
                return this.ger.bBJ();
            } catch (RemoteException e) {
            }
        }
        return fnw.bAy();
    }

    public final void bBc() {
        fno bBh;
        if (bBj() && (bBh = bBh()) != null && bBh.gcA != null) {
            R(bBh.gcA.gcE);
        }
    }

    public final long bBd() {
        if (this.ger == null) {
            return ebg.eyB;
        }
        try {
            return this.ger.bBO();
        } catch (Throwable th) {
            return ebg.eyB;
        }
    }

    public final long bBe() {
        if (this.ger != null) {
            try {
                long bBQ = this.ger.bBQ();
                if (bBQ != -1) {
                    return bBQ;
                }
            } catch (Throwable th) {
            }
        }
        return ebg.eyG;
    }

    public final long bBf() {
        if (this.ger != null) {
            try {
                long bBS = this.ger.bBS();
                if (bBS != -1) {
                    return bBS;
                }
            } catch (Throwable th) {
            }
        }
        return ebg.eyG;
    }

    public final long bBg() {
        if (this.ger != null) {
            try {
                long bBR = this.ger.bBR();
                if (bBR != -1) {
                    return bBR;
                }
            } catch (Throwable th) {
            }
        }
        return ebg.eyD;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0046, code lost:
        r1 = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:27:0x006e, code lost:
        r0 = e;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Removed duplicated region for block: B:15:0x0031  */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x0045 A[ExcHandler: RemoteException (e android.os.RemoteException), Splitter:B:2:0x0008] */
    /* JADX WARNING: Removed duplicated region for block: B:9:0x001d  */
    public final fno bBh() {
        fno fno;
        fno fno2;
        String str;
        bBa();
        if (this.ger != null) {
            try {
                str = this.ger.bBM().getString("key_result");
                fno = TextUtils.isEmpty(str) ? null : (fno) JSONUtil.instance(str, fno.class);
            } catch (RemoteException e) {
            } catch (Exception e2) {
                Exception e3 = e2;
                str = null;
                lve.a("WARN", TAG, "getUserInfo error! " + str, e3);
                fno = null;
            }
            if (fno == null) {
                String bAA = fnw.bAA();
                if (!TextUtils.isEmpty(bAA)) {
                    try {
                        fno2 = (fno) JSONUtil.instance(bAA, fno.class);
                    } catch (Exception e4) {
                        lve.a("ERROR", TAG, "[Session] user info load from json error.", e4);
                    }
                    if (fno2 == null) {
                        lve.ai("ERROR", TAG, "[Session] user info is null.");
                    }
                    return fno2;
                }
            }
            fno2 = fno;
            if (fno2 == null) {
            }
            return fno2;
        }
        fno = null;
        if (fno == null) {
        }
        fno2 = fno;
        if (fno2 == null) {
        }
        return fno2;
    }

    /* access modifiers changed from: protected */
    /* JADX WARNING: Removed duplicated region for block: B:13:0x002b  */
    /* JADX WARNING: Removed duplicated region for block: B:5:0x0010  */
    public final boolean bBj() {
        boolean z;
        boolean z2 = false;
        bBa();
        if (this.ger != null) {
            try {
                z = this.ger.bBK();
            } catch (RemoteException e) {
                lve.a("ERROR", TAG, "[Session] check is logined error!", e);
            }
            if (!z) {
                z2 = z;
            } else if (!TextUtils.isEmpty(fnw.bAy())) {
                z2 = true;
            }
            ebi.hG(z2);
            return z2;
        }
        z = false;
        if (!z) {
        }
        ebi.hG(z2);
        return z2;
    }

    @Override // defpackage.sym
    public final String bBk() {
        return "https://securitydoc.wps.cn";
    }

    public final void lf(boolean z) {
        if (bBj()) {
            fno bBh = bBh();
            if (bBh != null && bBh.gcB != null && bBh.gcB.gbu != null) {
                Q(bBh.gcB.gbu.gby);
            } else if (z && this.ger != null) {
                try {
                    this.ger.c(new foy() {
                        /* class defpackage.fof.AnonymousClass3 */

                        @Override // defpackage.foy, defpackage.Cfor
                        public final void onSuccess() throws RemoteException {
                            fof.this.lf(false);
                        }
                    });
                } catch (Exception e) {
                }
            }
        }
    }

    public final void lg(boolean z) {
        if (this.ger != null) {
            try {
                this.ger.lj(z);
            } catch (RemoteException e) {
            }
        }
    }
}